
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
run-callback
Advanced tools
Run async or sync callbacks, such as gulp tasks.
The main ideas are borrowed from orchestrator.
var run = require('run-callback');
Run callback
with arguments following callback
.
Type: Function
callback
can be made asynchronous if it does one of the following:
var run = require('run-callback');
run(
function (a, b) {
return new Promise(function (rs) {
rs(a + b);
});
},
2, 1,
function (err, sum) {
console.log('Expected:', 3);
console.log('Actual:', sum);
}
);
var run = require('run-callback');
var Stream = require('stream');
var res = [];
run(
function (a, b) {
var rs = Stream.Readable({ objectMode: true });
var data = [a, b];
rs._read = function () {
if (data.length) {
this.push(data.pop());
} else {
this.push(null);
}
};
process.nextTick(function () {
rs.on('data', function (d) {
res.push(d);
});
});
return rs;
},
1,
2,
function (err) {
console.log('Expected:', [2, 1]);
console.log('Actual:', res);
}
);
That extra argument should be a function.
var run = require('run-callback');
run(
function (a, b, done) {
process.nextTick(function () {
done(null, a + b, a - b);
});
},
2, 1,
function (err, sum, diff) {
console.log('Expected:', 3, 1);
console.log('Actual:', sum, diff);
}
);
Type: Function
Signature: done(err, val1, val2,...)
done
will be called when callback
finishes.
Errors thrown when executing callback
will be passed to done
as the first argument,
and the returned value as the second.
var run = require('run-callback');
run(
function (a, b) {
return a + b;
},
1, 2,
function (err, res) {
console.log('Expected:', 3);
console.log('Actual:', res);
}
);
done
will be called when the returned promise resolves.
Any rejected values will be passed as the first arugment, and any fulfilled values as the second.
done
will be called when the returned stream ends (readable, transforms, duplex) or finishes (writable).
Errors will be passed as the first arugment.
done
will be called when callback
invokes the last argument (next
) with a possible error object and more values.
done
will be called with the same arguments with next
.
Type: Object
If specified, it will be used as the execution context of callback
.
Type: Function
, String
If String
, it should be a method name of ctx
,
and that method will be treated as the callback
.
The arguments following callback
will be passed as arguments to callback
when it is executed.
FAQs
Run async & sync callbacks
The npm package run-callback receives a total of 38 weekly downloads. As such, run-callback popularity was classified as not popular.
We found that run-callback demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.